local jiuchi = fk.CreateSkill {

  name = "joy__jiuchi",

  tags = {  },

}



jiuchi:addEffect("viewas", {
  name = "joy__jiuchi",
  anim_type = "offensive",
  pattern = "analeptic",
  prompt = "你可以将一张黑色牌当做【酒】使用。",
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Black 
  end,
  view_as = function(self, player,cards)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("analeptic")
    c.skillName = jiuchi.name
    c:addSubcard(cards[1])
    return c
  end,
})

jiuchi:addEffect("targetmod", {
  name = "#joy__jiuchi_targetmod",
  bypass_times = function(self, player, skill, scope)
    return player:hasSkill(jiuchi.name) and skill.trueName == "analeptic_skill" and scope == Player.HistoryTurn
  end,
})

jiuchi:addEffect(fk.Damage, {
  name = "#joy__jiuchi_trigger",
  events = {fk.Damage},
  mute = true,
  --jiuchi,
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(jiuchi.name) and data.card and data.card.trueName == "slash"
        and player:getMark("@@joyex__benghuai_invalidity-turn") == 0 then
      local parentUseData = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if parentUseData then
        local drankBuff = parentUseData and (parentUseData.data[1].extra_data or {}).drankBuff or 0
        return drankBuff > 0
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player,jiuchi.name,nil,"酒池：是否摸一张牌并令本回合〖崩坏〗失效？")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, "joy__jiuchi", "drawcard")
    player:broadcastSkillInvoke("joy__jiuchi")
    player:drawCards(1,jiuchi.name)
    if not player.dead then
      room:addPlayerMark(player, "@@joyex__benghuai_invalidity-turn")
    end
  end,
})

jiuchi:addEffect("invalidity", {
  name = "#joy__jiuchi_invalidity",
  invalidity_func = function(self, from, skill)
    return from:getMark("@@joyex__benghuai_invalidity-turn") > 0 and skill.name == "joyex__benghuai"
  end
})

return jiuchi